import i18nInstance from "../../miniprogram_npm/miniprogram-i18n-plus/index"
import { config } from "../../config/index"
Page({
  data: {
    searchValue: '',// 存储搜索框的内容
    productsPro: [
      { id: 1, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/1.1.png', name: 'H9S单滴系列回转式制瓶机', description: '360°同步正吹气机构', type: '旗舰产品' },
      { id: 2, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/1.png', name: 'H9S双滴系列回转式制瓶机', description: '成模360°冷却', type: '旗舰产品' },
      { id: 3, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/2.png', name: 'H8S系列回转式制瓶机', description: '多分布变频同步', type: '主力产品' },
      { id: 4, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/3.png', name: '多料重伺服供料机', description: '与制瓶机实现同步', type: '制瓶机最佳伴侣' },
      { id: 4, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/3.png', name: '多料重伺服供料机', description: '与制瓶机实现同步', type: '制瓶机最佳伴侣' }
      // 添加更多成品商品
    ],
    productsApp: [
      { id: 5, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/4.png', name: '机器人应用1', description: '这是机器人应用1的简介' },
      // 添加更多机器人应用商品
    ],
    productsSys: [
      { id: 6, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/5.png', name: '配料系统1', description: '这是配料系统1的简介' },
    ],
    productsAtt: [
      { id: 7, image: 'https://gitee.com/Fanjuns/picture/raw/master/chuda/6.png', name: '配件1', description: '这是配件1的简介' },
      // 添加更多配件商品
    ]
  },
  // 处理输入事件
  onInput(e) {
    this.setData({
      searchValue: e.detail.value
    });
  },
  // 处理回车键触发的搜索事件
  onSearch() {
    const query = this.data.searchValue;
    if (query) {
      // 执行搜索逻辑，例如请求数据或更新视图
      wx.showToast({
        title: `搜索: ${query}`,
        icon: 'none'
      });
    } else {
      wx.showToast({
        title: '请输入搜索内容',
        icon: 'none'
      });
    }
  },
  onShow() {
    this.getTabBar().init();
    this.init();
  },
  init() {
    var that = this;
    wx.request({
      url: config.baseUrl + "/GetmachineList?lang=" + wx.getStorageSync('lang'),
      method: "GET",
      success(e) {
        console.log(e.data);
        that.setData({
          productsPro: e.data
        })
      }
    })
  },
  onLoad() {
    i18nInstance.effect(this);
  }
})